import 'package:flutter/material.dart';
import 'package:flutter_demo/res/resources.dart';
import 'package:flutter_demo/widgets/my_card.dart';

class BasicCard extends StatelessWidget {
  final Color color;
  final String leftTopTitle;
  final String rightTopTitle;
  final bool isShowTitleBar;
  final bool isShowRightTopWidget;
  final List<Widget> children ;
  final Icon leftTopTitleIcon;
  final Widget leftTopWidget;
  final Function onRight;

  const BasicCard({
    Key key,
    this.color,
    this.leftTopTitle,
    this.rightTopTitle,
    this.isShowTitleBar = true,
    this.isShowRightTopWidget = true,
    this.children,
    this.leftTopTitleIcon,
    this.leftTopWidget,
    this.onRight,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return 
    Padding(
      padding: const EdgeInsets.symmetric(horizontal: 10.0,vertical: 5.0),
      child: MyCard(
        color: color,
        child: Container(
          padding: const EdgeInsets.only(top:15.0),
          child: Column(
            children: <Widget>[
              !isShowTitleBar?Container():
                Column(
                  children: <Widget>[
                    Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: <Widget>[
                        Gaps.hGap20,
                        leftTopTitleIcon==null?
                          Container(
                            height: 18.0,
                            width: 4.0,
                            decoration: new BoxDecoration(
                              color:Color(0xFF6482FE),
                              borderRadius: BorderRadius.all(Radius.circular(2.0)),
                            ),
                          )
                          :Row(
                            children: <Widget>[
                              leftTopTitleIcon,
                              Gaps.hGap4,
                            ],
                          ),
                        Gaps.hGap8,
                        leftTopWidget == null?
                          Expanded(
                            child: Text(
                              '$leftTopTitle',
                              style: TextStyle(fontSize: Dimens.font_sp18,fontWeight: FontWeight.bold),                              
                            ),
                          ):leftTopWidget,
                        !isShowRightTopWidget?Gaps.empty
                          :InkWell(
                            onTap: onRight,
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.start,
                              crossAxisAlignment: CrossAxisAlignment.center,
                              children: <Widget>[
                                rightTopTitle==null?Gaps.empty:
                                Text(
                                  '$rightTopTitle',
                                  style: TextStyle(fontSize: Dimens.font_sp14,color:Colours.text_gray),
                                ),
                                Icon(
                                  Icons.keyboard_arrow_right,
                                  size:25,
                                  color:Colours.text_gray
                                ),
                                Gaps.hGap20,
                              ],
                            ),
                          ),
                          

                      ],
                    ),
                    Gaps.vGap20,
                    Divider(height: 1,color:Colours.line,),
                    // Gaps.vGap10,
                  ],
                ),
              children == null?
                Container(
                  margin: EdgeInsets.symmetric(vertical:20.0),
                  child: Center(
                    child: Text('没有任何信息!'),
                  ),
                ):
                Container(
                  margin: EdgeInsets.symmetric(horizontal:10.0),
                  child:Column(
                    children: children,
                  ),
                ),
              Gaps.vGap15,
            ],
          )
        ),
      ),
    );
  }
}